// These are meant to be typed into the REPL. You can also run
// scala -Xnojline < repl-session.scala to run them all at once.

/**
 * Scala得Int没有实现Comparable接口，但是RichInt实现了，我们需要隐式转换
 * [T <% Comparable[T]] 会将 T 隐式转换为 RichT 类型
 */

//视图界定
class PairSec04[T <% Comparable[T]](val first: T, val second: T) {
  def smaller = if (first.compareTo(second) < 0) first else second
  override def toString = "(" + first + "," + second + ")"
}

val p = new PairSec04(4, 2) // Works
p.smaller


